package com.googlecode.wheres_my_stuff_okay_potato;

import java.util.List;

import junit.framework.Assert;

/**
 * This utility class runs JUnit tests on Global.addLostItem().
 * 
 * @author Tucker Elliott
 */
public class TuckerJUnitTests {
	private Global global = new Global();
	private final User USER = global.getUser("Burrito");
	private final LostItem[] ITEMS = {
			new LostItem("TestItem0", "TestDesc0", "TestLoc0", USER, "Books"),
			new LostItem("TestItem1", "TestDesc1", "TestLoc1", USER,
					"Documents/Papers"),
			new LostItem("TestItem2", "TestDesc2", "TestLoc2", USER, "Jewelry"),
			new LostItem("TestItem3", "TestDesc3", "TestLoc3", USER, "Other"),
			new LostItem("TestItem4", "TestDesc4", "TestLoc4", USER, "Books"),
			new LostItem("TestItem5", "TestDesc5", "TestLoc5", USER,
					"Documents/Paper"),
			new LostItem("TestItem6", "TestDesc6", "TestLoc6", USER, "Jewelry"),
			new LostItem("TestItem7", "TestDesc7", "TestLoc7", USER, "Other") };
	private boolean alreadyAdded = false;

	private void addLostItems() {
		for (LostItem i : ITEMS)
			global.addLostItem(i);

		alreadyAdded = true;
	}

	public void testAddLostItem0() {
		List<Item> LostItems = global.getLostItems();
		for (LostItem i : ITEMS)
			// Items shouldn't be here!
			Assert.assertFalse(LostItems.contains(i));
	}

	public void testAddLostItem1() {
		if (!alreadyAdded)
			addLostItems();
		List<Item> LostItems = global.getLostItems();
		for (LostItem i : ITEMS)
			// Items should be here!
			Assert.assertTrue(LostItems.contains(i));
	}

	public void testAddLostItem2() {
		if (!alreadyAdded)
			addLostItems();
		List<Item> LostItems = global.getCurrentUserItems();
		for (LostItem i : ITEMS)
			// Items should still be here!
			Assert.assertTrue(LostItems.contains(i));
	}
}